import request from "@/utils/request";

export default {
  // 获取审批流程列表
  getApprovalFlowsList() {
    return request({
      url: "/approvalFlows/list",
      method: "get",
    });
  },

  // 添加审批流程
  addApprovalFlows(flow) {
    return request({
      url: "/approvalFlows/add",
      method: "post",
      data: flow,
    });
  },

  // 根据 id 获取审批流程
  getApprovalFlowsById(id) {
    return request({
      url: `/approvalFlows/${id}`,
      method: "get",
    });
  },

  // 删除审批流程
  deleteById(id) {
    return request({
      url: `/approvalFlows/delete/${id}`,
      method: "delete",
    });
  },

  // 更新审批流程
  updateById(flow) {
    return request({
      url: "/approvalFlows/update",
      method: "put",
      data: flow,
    });
  },

  // 统一保存（新增 or 更新）
  saveApprovalFlows(flow) {
    if (flow.id) {
      return this.updateById(flow);
    } else {
      return this.addApprovalFlows(flow);
    }
  },
};
